﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Objects;

namespace System.Data
{
    public static class ObjectStateManagerExtensions
    {
        public static void ControlStateByCondition<T>(this ObjectStateManager source, T entity, Func<T, bool> condition)
        { 
            source.ChangeObjectState(entity, condition(entity) ? EntityState.Modified : EntityState.Added);
        }
    }
}